<template>
	<view class="page-body">
		<view class="page-body-wrapper">
			<camera device-position="front" flash="off" frame-size="small" @error="error" class="camera">
				<cover-view class="cover-view">
					<cover-view class="cover-round"></cover-view>
				</cover-view>
			</camera>
		</view>
		<view class="uni-padding-wrap uni-common-mt">
			<view class="button-sp-area">
				<button type="primary" @click="takePhoto">拍照</button>
			</view>
		</view>
	</view>
</template>
<style>
	.page-body-wrapper {
		margin-top: 100rpx;
	}

	.camera {
		width: 100%;
		height: 750rpx;
		background-color: #fff;
	}

	.cover-view {
		width: 100%;
		height: 750rpx;
		text-align: center;
		background-color: transparent;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.cover-round {
		position: absolute;
		width: 600rpx;
		height: 600rpx;
		border-radius: 50%;
		border: 500rpx solid #ffffff;
	}
</style>
<script>
	export default {
		data() {
			return {
				src: ""
			}
		},
		methods: {
			takePhoto() {
				const ctx = uni.createCameraContext();
				ctx.takePhoto({
					quality: 'high',
					success: (res) => {
						uni.navigateTo({
							url: "/pages/mine/cert-upload?img=" + res.tempImagePath
						})
					}
				});
			},
			error(e) {
				uni.showModal({
					title: '操作提示',
					content: '出错了，请稍候再试！',
					showCancel: false
				})
			}
		}
	}
</script>
